#include "serverwrite.h"

#include <unistd.h>
#include <string.h>
#include <QDebug>

ServerWrite::ServerWrite(QObject *parent)
    : QObject{parent}
{

}

void ServerWrite::writing(int clientFd)
{
    qDebug() << "serverWrite: start write" << clientFd;
    m_clientFd = clientFd;
}

void ServerWrite::sendMyMsg(QString msg)
{
    qDebug() << "serverWrite: ready to send" << msg;
    QByteArray byteArray = msg.toUtf8();
    const char* charArray = byteArray.constData();
    ::write(m_clientFd, charArray, strlen(charArray) + 1);
}
